
import 'package:flutter/material.dart';
import 'package:personinfo/utils/ColorUtil.dart';

/**
 * labelText  左侧label
 * placeholder 提示语
 * onTap 点击事件
 * showIcon 是否展示icon
 * val 返回值
 */
Widget Vanfeild({required String labelText, String placeholder="请选择", GestureTapCallback? onTap, bool showIcon=true, String ? val}){
  return GestureDetector(
    onTap: onTap,
    child: Container(
      padding: EdgeInsets.fromLTRB(0, 12, 0, 10),
      decoration: BoxDecoration(
        border: Border(
          // 划线位置、线宽、颜色
          bottom: BorderSide(width: 1.0, color: Color.fromRGBO(214, 214, 214, 1)),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(labelText,style: TextStyle(color: Colors.black),),
          Row(
            children: [
              if(val!=null)
                Text(val,style: TextStyle(color: Colors.black),),
              if(val == null)
                Text(placeholder,style: TextStyle(color: Color.fromRGBO(154, 154, 154, 1)),),
              if(showIcon)
                Icon(Icons.keyboard_arrow_right,color: ColorUtil.greyColor,)
            ],
          )
        ],
      ),
    ),
  );
}

/**
 * labelText  左侧label
 */
Widget VandInfo({required String labelText, GestureTapCallback? onTap, String ? val, Color color=Colors.black
  ,Color backgroundColor=Colors.white
}){
  return GestureDetector(
    onTap: onTap,
    child: Container(
      padding: EdgeInsets.fromLTRB(20, 12, 20, 10),
      decoration: BoxDecoration(
        color: backgroundColor,
        border: Border(
          // 划线位置、线宽、颜色
          bottom: BorderSide(width: 1.0, color: Color.fromRGBO(214, 214, 214, 1)),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(labelText,style: TextStyle(color: color),),
        ],
      ),
    ),
  );
}